/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.info.service.plugins  
 */
package com.apache.info.service.plugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.info.entity.PubSortInfo;
import com.apache.info.manager.InfoReleaseManager;

/**
 * description:  动态删除表操作
 * @author Hou Dayu 创建时间：2015-8-28  
 * @Copyright(c)2014:北京--软件技术有限公司
 */
public class DynamicDropTablePluginImpl implements PluginConnector {

	private InfoReleaseManager infoReleaseManager;

	/**
	 * TODO 动态删除表插件实现.  
	 * @see com.apache.api.manager.PluginConnector#execute(com.apache.api.vo.ParamsVo)  
	 */
	public Object execute(ParamsVo vo) throws Exception {
		PubSortInfo sort = (PubSortInfo) vo.getParams("sort");

		vo.setKey("");
		vo.setParams("dyncSql", dropTableSqlForOracle(sort.getInfoTableName()));
		vo.setParams("sort", sort);
		return infoReleaseManager.deleteInfo(vo);
	}

	private String dropTableSqlForOracle(String tableName) {
		//alter   table   表名  drop  column   列名
		String sql = "drop table " + tableName;
		return sql;
	}

	public void setInfoReleaseManager(InfoReleaseManager infoReleaseManager) {
		this.infoReleaseManager = infoReleaseManager;
	}

}
